date routine
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 614
- Joined: Fri Feb 06, 2004 3:59 pm
date routine
Hi all,
iam using following code in my routine
if (Not(IsNull(Trim(Arg1)))) Then
Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End Else
Ans = Oconv(Date(),'D4/MDY')
End
if my input is and empty string then iam not getting today's date.
Any help greatly appreciated.
Thank you all
iam using following code in my routine
if (Not(IsNull(Trim(Arg1)))) Then
Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End Else
Ans = Oconv(Date(),'D4/MDY')
End
if my input is and empty string then iam not getting today's date.
Any help greatly appreciated.
Thank you all
Re: date routine
Try "if (Not(IsNull(Trim(Arg1)))) and Arg1 # '' Then ....".
Regu
Regu
-
- Premium Member
- Posts: 614
- Joined: Fri Feb 06, 2004 3:59 pm
Thank you Regu,
Though i did not get the reason why you asking me to do like that
still i did in my code , but now iam getting compilation error.
compilation error is
Compiling: Source = 'DSU_BP/DSU.OraDatetimestamp', Object = 'DSU_BP.O/DSU.OraDatetimestamp'
0002 if (Not(IsNull(Trim(Arg1)))) and Arg1 # Then
^
"THENEOL" unexpected, Was expecting: '=', "LT", "LE", "GT", "GE", "NE",
"EQ", "MATCH"
1 Errors detected, No Object Code Produced.
Can any one help me,
Though i did not get the reason why you asking me to do like that
still i did in my code , but now iam getting compilation error.
Code: Select all
if (Not(IsNull(Trim(Arg1)))) and Arg1 # Then
Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End Else
Ans = Oconv(Date(),'D4/MDY')
End
Compiling: Source = 'DSU_BP/DSU.OraDatetimestamp', Object = 'DSU_BP.O/DSU.OraDatetimestamp'
0002 if (Not(IsNull(Trim(Arg1)))) and Arg1 # Then
^
"THENEOL" unexpected, Was expecting: '=', "LT", "LE", "GT", "GE", "NE",
"EQ", "MATCH"
1 Errors detected, No Object Code Produced.
Can any one help me,
You missed out the '' (empty string).
So your code should be
You need to remember that nulls are not always the same as empty strings.
Regu.
So your code should be
Code: Select all
if (Not(IsNull(Trim(Arg1)))) and Arg1 # '' Then
Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End Else
Ans = Oconv(Date(),'D4/MDY')
End
Regu.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Trim() won't help the test. If it's null, it's null. You can simpllfy your logic. Reversing the logic will remove the need for Not(). And you can be less specific about the format for Iconv().
Code: Select all
If IsNull(Arg1) Then
Ans = Oconv(Date(),'D4/MDY')
End Else
Ans = Oconv((Iconv(Trim(Arg1),"DMDY")), "D4/MDY[2,2,4]")
End
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 614
- Joined: Fri Feb 06, 2004 3:59 pm
Thank you Regu,
I agree to you that nulls are not same empty string , i need to insert
date in a timestamp field in a oracle table ,
if my input is an empty strin or spaces when trim it it is a null value.
so in place of empty string , i need to insert system date that is what iam
doing in the else part.
does oracle all to insert null values in a timestamp field thru ora oci
stage
Can you any help me,
Thank you all.
I agree to you that nulls are not same empty string , i need to insert
date in a timestamp field in a oracle table ,
if my input is an empty strin or spaces when trim it it is a null value.
so in place of empty string , i need to insert system date that is what iam
doing in the else part.
does oracle all to insert null values in a timestamp field thru ora oci
stage
Can you any help me,
Thank you all.
-
- Premium Member
- Posts: 614
- Joined: Fri Feb 06, 2004 3:59 pm
Hi all ,
Thanks for all your answers
i acheived in the following way,
That worked,
Thank you
Thanks for all your answers
i acheived in the following way,
Code: Select all
if Len(Trim(Arg1)) = '0' Then
Ans = Oconv(Date() , "D4/MDY")
End Else
Ans = Oconv((Iconv(Trim(Arg1),"D/MDY[Z,Z,4]")), "D4/MDY[2,2,4]")
End
Thank you