How to compare date with null value
Hi
I have a date filed and i assigned that input box with context attribute of type Date.
Here my problem is
when the end user not entered any thing (null ) the i have give some defaul date.
so first in the action method i have to check the date with null
if it is null i have to give default date.
so please let me know how to over come this.
thanks
Mukesh
Hi
You can get your date in your action method like
Date newDate=new Date();
Date myDate= wdThis
.wdGetYourComponentNameController()
.wdGetContext()
.currentYourNodeNameElement()
.getYourDateName();
if ( myDate== null) {
wdContext.currentContextElement().setYourDateName(newDate);
else{...........//continue your other validations or calling other methods}
Regards
Abhijith YS
Message was edited by:
Abhijith YS
Similar Messages
-
How to Compare date with Current system date in XSLT mapping.
Hello Experts
In a XSLT mapping program, I hava a filed, ZZOB which is giving some date.
which I need to compare with the current date.
Condition-
ZZOB is greater than current date or ZZOBLIG = NULL
Then go further statements.
how can i campare with the current date?
Please help.
Thanks
BalaprasadThis example may help:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="currentDate"/>
<xsl:variable name="firstDate" select="concat(substring($currentDate, 1,4),substring($currentDate, 6,2),substring($currentDate, 9,2))"/>
<xsl:template match="/">
<xsl:apply-templates select="//item"/>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="secondDate" select="concat(substring(submissionDeadline, 1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline, 9,2))"/>
<xsl:choose>
<xsl:when test="$firstDate > $secondDate">
<xsl:call-template name="late"/>
</xsl:when>
<xsl:when test="$firstDate < $secondDate">
<xsl:call-template name="ontime"/>
</xsl:when>
<xsl:when test="$firstDate = $secondDate">
<xsl:call-template name="same"/>
</xsl:when>
<xsl:otherwise>Monkeys<br /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ontime">
This is on time
</xsl:template>
<xsl:template name="late">
This is late
</xsl:template>
<xsl:template name="same">
This is on time
</xsl:template>
</xsl:stylesheet> -
How to compare date with thr current date
Hi,
I have an inout string which is in date format(dd/mm/yyyy hh:mm:ss) .
what i need to do is comparing this date string with the current date. if my input string is less than current date , then display error message..
how to do this?
regardsExcellent suggestions from all of you people!
finally i got the solution
code is:
import java.util.*;
import java.text.*;
public class TestDate {
public static void main(String args[]){
TestDate a = new TestDate();
TestDate() {
String DATE_FORMAT = "dd/MM/yyyy hh:mm:ss";
Date today = new Date();
Date myDate=null;
java.text.SimpleDateFormat sdf =
new java.text.SimpleDateFormat(DATE_FORMAT);
try{
myDate = sdf.parse("01/06/2006 00:00:00");
}catch(Exception e) {System.out.println(e);}
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(today);
c2.setTime(myDate1);
System.out.print(sdf.format(today));
System.out.print(sdf.format(c1.getTime()));
if (c1.before(c2)) {
System.out.print(" is before ");
if (c1.after(c2)) {
System.out.print(" is after ");
if (c1.equals(c2)) {
System.out.print(" same as ");
System.out.print(sdf.format(c2.getTime()));
} -
hi
i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
Regardsuser10502390 wrote:
hi
i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
RegardsPoint a) VERY BAD IDEA storing dates as VARCHAR2 on the database. It will only lead to corrupt data in the future.
Point b) When comparing dates, you should compare them as DATE datatype as the database knows how to do comparisons against DATES. If you try and compare them as VARCHAR2 then you will most likely end up with incorrect comparisons.
If you must have varchar2 storing of your dates/times (there's absolutely no reason to though)... you want...
TO_DATE(:entered_date,'YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')
e.g.
TO_DATE('20080815 13:23:33','YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS') -
How to select columns with null values
HI
In my table ‘A’ I have 10 columns and 30,000 records. I need all those columns whose value is null for all the records.
For example in the below table column 'suffix' is null for all the records. So I want column suffix to be selected.
Name Suffix Street
James 1100 Washington street
Richard 273 GEORGIA ST
Arnold 3018 OAKHILL AVE
MICHAEL 834 E 161ST ST
Joseph 410 PINE AVE
Thanks in advanceTrue...
But, i think here null needs to handle otherwise it will again throw some error like this ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.20
satyaki>
satyaki>
satyaki>
satyaki>SELECT owner, table_name, column_name
2 FROM all_tab_cols
3 WHERE data_type NOT IN ('BLOB', 'LONG', 'CLOB')
4 AND dbms_xmlgen.getxmltype('select count('
5 || CASE
6 WHEN data_type NOT IN
7 ('BLOB', 'LONG', 'CLOB')
8 THEN
9 column_name
10 ELSE
11 '1'
12 END
13 || ') c from '
14 || owner
15 || '.'
16 || table_name).EXTRACT (
17 '//text()'
18 ).getnumberval () = 0
19 AND table_name IN
20 (SELECT table_name
21 FROM all_tab_privs
22 WHERE privilege = 'SELECT' AND USER IN (grantor, grantee));
ERROR:
ORA-19202: Error occurred in XML processing
ORA-24347: Warning of a NULL column in an aggregate function
ORA-06512: at "SYS.DBMS_XMLGEN", line 288
ORA-06512: at line 1
no rows selected
Elapsed: 00:00:04.03
satyaki>Or,
satyaki>
satyaki>
satyaki>SELECT table_name, column_name
2 FROM user_tab_cols
3 WHERE data_type NOT IN ('BLOB', 'LONG', 'CLOB')
4 AND dbms_xmlgen.getxmltype('select count('
5 || CASE
6 WHEN data_type NOT IN ('BLOB', 'LONG', 'CLOB') THEN
7 column_name
8 ELSE
9 '1'
10 END
11 || ') c from '||table_name).EXTRACT('//text()').getnumberval() = 0;
AND dbms_xmlgen.getxmltype('select count('
ERROR at line 4:
ORA-19202: Error occurred in XML processing
ORA-24347: Warning of a NULL column in an aggregate function
ORA-06512: at "SYS.DBMS_XMLGEN", line 288
ORA-06512: at line 1
Elapsed: 00:00:02.66
satyaki>
satyaki>Do you have any idea to resolve this issue in this context?
Regards.
Satyaki De. -
Import data with nulls in Desktop Intelligence
Hello,
I have data with null values (in a measure). If I export the data as CSV it shows null values as #EMPTY. If I use that as a datasource, it loads #EMPTY as 0 (zero).
Is there a way to make desktop intelligence recognize null values? I tried to remove the #empty and just leave the column empty, it still loads as a numeric zero.
Same (actually worse) for XML. It seems if I export my data to XML it can not use that as a datasource. Odd. So I created the following XML file:
<?xml version='1.0' encoding='UTF-8'?>
<data>
<item key="AAAAAEUK" value="130" category="A" />
<item key="AAAACGDC" value="66" category="A" />
<item key="AAAADNJP" value="56" category="A" />
<item key="AAAAFWRQ" value="222" category="A" />
<item key="AAAAGITU" category="B" />
</data>
I would expect the value field to be null for the last row. But the values turns out to be 222! If I try to put anything else, an empty string "", "#EMPTY", "null", it is always returned as 0.
This is a problem because 0 an null are differnt when computing averages.Hi Florian,
What is the source of your csv data?
If I have a table in excel with empty cells, the data goes into the .csv as nothing so your example would look like
Item key,value,category
AAAAAEUK,130,A
AAAACGDC,66,A
AAAADNJP,56,A
AAAAFWRQ,222,A
AAAAGITU,,B
This reads in just fine in DeskI (shows #EMPTY in the view data, treats it as such in the report).
So I would look to get the data generated in right way, then DeskI can handle it, no problem.
If all else fails, just run a search&replace and change ,#EMPTY, to ,,
BTW if you have an alphanumeric value in a column where DeskI already decided there should be numeric,
it will read in as 0, that is why the #EMPTY string value got transformed to zero.
Good luck,
Marianne -
JDBC MS Access--- cannot extract entry with null value with data type Meta
I'm trying to extract a data entry with null value by using JDBC. The database is MS Access.
The question is how to extract null entry with data type memo? The following code works when the label has data type Text, but it throws sqlException when the data type is memo.
Any advice will be appreciated! thanks!
Following are the table description and JDBC code:
test table has the following attributes:
Field name Data Type
name Text
label Memo
table contents:
name label
me null
you gates
Code:
String query = "SELECT name, label FROM test where name like 'me' ";
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
String name = rs.getString("name");
rs.getString("val");
String label = rs.getString("label");
System.out.println("\t"+name+"\t"+label);
catch (SQLException ex)
System.out.println(ex.getSQLState());
System.out.println(ex.getErrorCode());
System.out.println("in sqlexception");
output:
C:\Temp\SEFormExtractor>java DBTest
yet SELECT name, label FROM test
null
0
in sqlexceptionThe question is how to extract null entry with data type memo?Okay, what you need to do is this:
if (rs.getString("val") == null)
// do something
}This way, when it's a null value, you can check it first, and then handle it how you want, rather than getting an exception. -
How to create a dimension object in SAP BW Unv with Null value
Hello,
for query syncronisation task, I need a dimension object in my BW universe with NULL value. Does someone know, how to do it or if its possible?
Regards,
ThiloHi Thilo,
so the only common item is Material then - correct ?
Query 1 Query 2
Formulation (grouping of materials) (No counterpart)
Material Material
dummy key figure (why?) Company Code
10 Keyfigure
Is this something you regular have to do ? what about a MultiProvider ?
did you try "merged dimensions" in the Web Intelligence Report ?
Ingo -
How to compare date which is greatest date
iam new to sql
how to compare date which date is greatest date with example
can i use to_char to compare date
SELECT eno, ename, GREATEST (TBLE.MAX1, TBLE.MAX2) recent_date "
FROM (SELECT TBLA.eno, TBLA.ename, "
MAX (TO_CHAR (TBL.date1, 'MM/DD/YYYY HH24:MI') "
) MAX1, "
MAX (TO_CHAR (TBL.date2, 'MM/DD/YYYY HH24:MI') "
) MAX2 "
FROM dual TBL, dual2 TBLA
in above query if any one of the date having null value then recent_date is showing 'null'
and also it showing wrong value
example
date1='08-22-2009' and date2='01-23-2010' then it showing wrong recent_datel ike='08-22-2009'
as according my knowledge it is comparing with month it sholud not be like this wat i have to do pls explain with example my o/p should come for recent_date like =''01-23-2010''
Edited by: user9112274 on Aug 27, 2010 5:31 AMHi,
there are numerous ways to compare dates, i give you some examples:
with data_Sample as
(select to_date('01-jan-2001','dd-mon-yyyy') d1, to_date('01-mar-2002','dd-mon-yyyy') d2, to_date('03-feb-2002','dd-mon-yyyy') d3 from dual)
select greatest(d1,d2,d3) from data_Sample
GREATEST(D1,D2,D3)
3/1/2002
with data_Sample as
(select to_date('01-jan-2001','dd-mon-yyyy') d1 from dual union all
select to_date('01-mar-2002','dd-mon-yyyy') from dual union all
select to_date('03-feb-2002','dd-mon-yyyy') from dual)
select max(d1) from data_Sample
MAX(D1)
3/1/2002
declare
d1 date :=to_date('01-jan-2001','dd-mon-yyyy');
d2 date :=to_date('01-jan-2001','dd-mon-yyyy');
begin
if d1>d2 then
dbms_output.PUT_LINE('d1 greater than d2');
else
dbms_output.PUT_LINE('d1 less or equql than d2');
end if;
end;
output:
d1 less or equal than d2now concerning your question:
>
can i use to_char to compare date
>
If you have date data types : don't convert them.
if you have no choice, use something like:
if to_char(d1,'YYYYMMDD') > to_char(d2,'YYYYMMDD') then
else
end if;Take care when you convert a date into a char format it becomes string comparison (with all it implies) (It's the reason why i've use an explicit mask format). -
Need help with NULL values in Crosstables
Hello everybody,
I need some help with NULL values and crosstables. My issue is the following:
I have a query (BW - MDX-Query) that gives me turnover measures for each month. In Crystal Reports I choose crosstable to display this whereby I put all month in columns and all turnover-measures in rows. Each month that has a value (measures are not empty) is chown in the crosstables rows. So far so good. The problem occures when there are month that actually have no values (measures are empty). In that case these months are not chown in columns. But I need CR to display these columns and show the value 0. How can I do that?Hi Frank,
Cross tab shows the data based on your column and these column fields are grouped and based on the group it will show your summaries.
If there is no data for any of your group it will not display that group. In this case you will have to create a standard report which should look like cross tab and to get zero values you need to write formulas .
Example if you want to display Moth wise sales :
if Month() = 01 Then
sum() else 0
Now this formula will check if your month is Jan, then it will sum up the values else it will display zero value.
This is possible only through standard report not with Cross Tab.
Thanks,
Sastry -
How to compare date and time together
Hi,
How to compare Date and Time together?
For example in a database table there are two fields rundate and runtime. I want to compare these two with perticular date and time in the program. Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
Hope the question is clear...
Thanks.
KavitaHi Kavita
There is no as such Date and Time Comparision FM in Standard SAP But You can define your own like this
<b>FUNCTION ZAV4_COMPAREDATETIME.
""Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(DATE1) TYPE DATS
*" REFERENCE(TIME1) TYPE TIMS
*" REFERENCE(DATE2) TYPE DATS
*" REFERENCE(TIME2) TYPE TIMS
*" EXPORTING
*" VALUE(TWOISMORETOPICAL) TYPE C
twoismoretopical = ''.
if date2 > date1.
twoismoretopical = 'X'.
else.
if date2 = date1 and time2 > time1.
twoismoretopical = 'X'.
endif.
endif.
ENDFUNCTION.</b>
Regards
Mithlesh -
To overcome column with null value-urgent
hai all,
when i query i get column with null value.
how to solve it?
thank in advance.
rcs
SQL> DESC SCOTT.CB1;
Name Null? Type
ID NUMBER
SUPCODE NUMBER
SUPLNAME VARCHAR2(100)
NAME VARCHAR2(100)
ITEMCODE VARCHAR2(10)
RECDOC NUMBER
RECDATE VARCHAR2(10)
TOTVALUE NUMBER
QTY NUMBER
CB_IPNO NUMBER
CB_VNNO NUMBER
CB_VDT VARCHAR2(10)
CB_AMT NUMBER
RECDOC_GR VARCHAR2(30)
RECDATE_GR DATE
SUPCODE_GR VARCHAR2(10)
TABLE LOOK LIKE THIS (NOT ALL DATA IN SAME ROW, BECUSE I INSERTED LAST 3 COLUMN VALUES):
ID SUPCODE SUPLNAME NAME ITEMCODE RECDOC RECDATE TOTVALUE QTY CB_IPNO CB_VNNO CB_VDT CB_AMT RECDOC_GR RECDATE_GR SUPCODE_GR
2015 AAAA 04117 9083 10545.6 78
2016 BBBB 04609 9087 25200 3600
2017 GGGG 04609 9088 28175 4025
2018 36591371.64 2565017.27
00001/07-08 02/04/2007 14020362
00002/07-08 02/04/2007 14020362
00003/07-08 02/04/2007 14010254
00004/07-08 02/04/2007 14010254
00005/07-08 02/04/2007 14021458
SQL> SELECT DISTINCT ID, SUPCODE_GR, NAME, ITEMCODE, RECDOC, RECDATE_GR, TOTVALUE, QTY FROM SCOTT.CB
1;
ID SUPCODE_GR
NAME
ITEMCODE RECDOC RECDATE_G TOTVALUE QTY
1
PRO.AT.ALU.POWDER UNCOATED
04609 15 51975 7425
2
PEN, GEL PEN
07969 17 154 11
ID SUPCODE_GR
I NEED RESULT AS FOLLOWS (ALL RESPECTIVE DDATA IN ONE LINE NOW NOT LIKE THAT):
ID SUPCODE SUPLNAME NAME ITEMCODE RECDOC RECDATE TOTVALUE QTY CB_IPNO CB_VNNO CB_VDT CB_AMT RECDOC_GR RECDATE_GR SUPCODE_GR
2015 AAAA 04117 9083 10545.6 78 00001/07-08 02/04/2007 14020362
============Even accounting for the formatting, I'm not sure I even understand the question. It could be any number of different problems or non-problems.
-
How do I set a NULL value for the parameter field
Hi
I've another question. I'm going to set single values for parameter fields.
// e.g. set today for StartDate parameter field
fc.setCurrentValue("", "StartDate", new Date());
It should be possible to set a NULL value for date parameter fields.
fc.setCurrentValue("", "StartDate", (Date)null);
But this do not work. How do I set a NULL value correctly?
Thank you in advance.
Best regards,
ThomasFirst question - is it a stored procedure parameter?
You can't set a regular parameter field value to a null value.
There was an issue with old version of the JRC, where it was allowing null to go through, but had unexpected behavior at times.
Sincerely,
Ted Ueda -
How does APEX check for null values in Text Fields on the forms?
Hello all,
How does APEX check for null values in Text Fields on the forms? This might sound trivial but I have a problem with a PL/SQL Validation that I have written.
I have one select list (P108_CLUSTER_ID) and one Text field (P108_PRIVATE_IP). I made P108_CLUSTER_ID to return null value when nothing is selected and assumed P108_PRIVATE_IP to return null value too when nothign is entered in the text field.
All that I need is to validate if P108_PRIVATE_IP is entered when a P108_CLUSTER_ID is selected. i.e it is mandatory to enter Private IP when a cluster is seelcted and following is my Pl/SQL code
Declare
v_valid boolean;
Begin
IF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NULL THEN
v_valid := TRUE;
ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NOT NULL THEN
v_valid := TRUE;
ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NULL THEN
v_valid := FALSE;
ELSIF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NOT NULL THEN
v_valid := FALSE;
END IF;
return v_valid;
END;
My problem is it is returning FALSE for all the cases.It works fine in SQL Command though..When I tried to Debug and use Firebug, I found that Text fields are not stored a null by default but as empty strings "" . Now I tried modifying my PL/SQL to check Private_IP against an empty string. But doesn't help. Can someone please tell me how I need to proceed.
ThanksSee SQL report for LIKE SEARCH I have just explained how Select list return value works..
Cheers,
Hari -
How to export data with column headers in sql server 2008 with bcp command?
Hi all,
I want know "how to export data with column headers in sql server 2008 with bcp command", I know how to import data with import and export wizard. when i
am trying to import data with bcp command data has been copied but column names are not came.
I am using the below query:-
EXEC master..xp_cmdshell
'BCP "SELECT * FROM [tempdb].[dbo].[VBAS_ErrorLog] " QUERYOUT "D:\Temp\SQLServer.log" -c -t , -T -S SERVER-A'
Thanks,
SAAD.Hi All,
I have done as per your suggestion but here i have face the below problem, in print statment it give correct query, in EXEC ( EXEC master..xp_cmdshell @BCPCMD) it was displayed error message like below
DECLARE @BCPCMD
nvarchar(4000)
DECLARE @BCPCMD1
nvarchar(4000)
DECLARE @BCPCMD2
nvarchar(4000)
DECLARE @SQLEXPRESS
varchar(50)
DECLARE @filepath
nvarchar(150),@SQLServer
varchar(50)
SET @filepath
= N'"D:\Temp\LDH_SQLErrorlog_'+CAST(YEAR(GETDATE())
as varchar(4))
+RIGHT('00'+CAST(MONTH(GETDATE())
as varchar(2)),2)
+RIGHT('00'+CAST(DAY(GETDATE())
as varchar(2)),2)+'.log" '
Set @SQLServer
=(SELECT
@@SERVERNAME)
SELECT @BCPCMD1
= '''BCP "SELECT
* FROM [tempdb].[dbo].[wErrorLog] " QUERYOUT '
SELECT @BCPCMD2
= '-c -t , -T -S '
+ @SQLServer +
SET @BCPCMD
= @BCPCMD1+ @filepath
+ @BCPCMD2
Print @BCPCMD
-- Print out below
'BCP "SELECT
* FROM [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername'
EXEC
master..xp_cmdshell
@BCPCMD
''BCP' is not recognized as an internal or external command,
operable program or batch file.
NULL
if i copy the print ourt put like below and excecute the CMD it was working fine, could you please suggest me what is the problem in above query.
EXEC
master..xp_cmdshell
'BCP "SELECT * FROM
[tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername '
Thanks, SAAD.
Maybe you are looking for
-
Disk Utility not functioning properly, unable to format disks
Installed Mountain Lion last week and am now trying to format a flash drive, but Disk Utility no longer has the ability to do anything at all. I can open it and look at my disks, but that's all I can do. All functions have essentially been locked o
-
Getting full 1080p to a Sharp Aquos 42'' HD LCD TV
Okay, I've been struggling and struggling with this one for a good month or two and I have pretty much use up all my lifelines except the apple forums I have a Sharp Aquos 42'' LCD HDTV that is 1080p capable, and has 2 HDMI inputs. I have been using
-
I've just bought QuickTime Pro - but I can't find where to download it - can you help?
I've just bought QuickTime Pro - but I can't find where to download it - can you help?
-
I just tried to update my laptop and now my laptop wont turn on?
i just tried to update my laptop and now my laptop wont turn on? what should i do?
-
Hi, I have a scenario..which i am explaining below My company has one sales organization and many divisions under it. Some divisions are service providing divisions. Service providing divisions give service to other divisions within the same sales or