Date Conversion
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 9
- Joined: Tue Apr 05, 2005 4:39 am
Date Conversion
Hai All,
I have a date field of the format 1/1/2005 and my output should look like 2005-01-01. How can i achieve this. Thanx in Advance
Regard's
RAVI
I have a date field of the format 1/1/2005 and my output should look like 2005-01-01. How can i achieve this. Thanx in Advance
Regard's
RAVI
Take a look in the Documentation and also in this forum at the StringToDate and DateToString functions.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 9
- Joined: Tue Apr 05, 2005 4:39 am
The output shows that the conversion wasn't successful, either because of a bad format or a bad input type date. If you are getting a Date type field from a database, you would first need to DateToString and then a StringToDate with the new format.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
StringToDate(ip.date,"%yyyy-%mm-%dd") specifies that the input string is in YYYY-MM-DD format. This is not how you originally represented the problem.
What you probably need is something of the form
What you probably need is something of the form
Code: Select all
DateToString(StringToDate(ip.date,"%mm/%dd/%yy"), "%yyyy-%mm-%dd")
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.
-
- Participant
- Posts: 9
- Joined: Tue Apr 05, 2005 4:39 am
-
- Participant
- Posts: 9
- Joined: Tue Apr 05, 2005 4:39 am
hai Ray,
I have got the output in this way
StageVariable1
if Len (Field(DSLink2.date_f,"/",1))=1 then "0":Field(DSLink2.date_f,"/",1) else Field(DSLink2.date_f,"/",1)
StageVariable2
if Len (Field(DSLink2.date_f,"/",2))=1 then "0":Field(DSLink2.date_f,"/",2) else Field(DSLink2.date_f,"/",2)
Concatenating both
StringToDate(Right(DSLink2.date_f,4):StageVar1:StageVar,"%yyyy%mm%dd")
I have got the result by doing this.
But i need to do it in simpler way. Any suggestions
Regard's
Ravi
I have got the output in this way
StageVariable1
if Len (Field(DSLink2.date_f,"/",1))=1 then "0":Field(DSLink2.date_f,"/",1) else Field(DSLink2.date_f,"/",1)
StageVariable2
if Len (Field(DSLink2.date_f,"/",2))=1 then "0":Field(DSLink2.date_f,"/",2) else Field(DSLink2.date_f,"/",2)
Concatenating both
StringToDate(Right(DSLink2.date_f,4):StageVar1:StageVar,"%yyyy%mm%dd")
I have got the result by doing this.
But i need to do it in simpler way. Any suggestions
Regard's
Ravi
This works...a little simpler...maybe
svDay
((Field(DSLink3.f1,'/',1))/100)[3,2]
svMonth
((Field(DSLink3.f1,'/',2))/100)[3,2]
svYear
Field(DSLink3.f1,'/',3)
StringToDate(svMonth:'/':svDay:'/':svYear,"%mm/%dd/%yyyy")
svDay
((Field(DSLink3.f1,'/',1))/100)[3,2]
svMonth
((Field(DSLink3.f1,'/',2))/100)[3,2]
svYear
Field(DSLink3.f1,'/',3)
StringToDate(svMonth:'/':svDay:'/':svYear,"%mm/%dd/%yyyy")
Lance Short
"infinite diversity in infinite combinations"
***
"The absence of evidence is not evidence of absence."
"infinite diversity in infinite combinations"
***
"The absence of evidence is not evidence of absence."
btw: You could also do it all in the derivation without the StageVariables
StringToDate(((Field(DSLink3.f1,'/',2))/100)[3,2]:'/':((Field(DSLink3.f1,'/',1))/100)[3,2]:'/':Field(DSLink3.f1,'/',3),"%mm/%dd/%yyyy")
StringToDate(((Field(DSLink3.f1,'/',2))/100)[3,2]:'/':((Field(DSLink3.f1,'/',1))/100)[3,2]:'/':Field(DSLink3.f1,'/',3),"%mm/%dd/%yyyy")
Lance Short
"infinite diversity in infinite combinations"
***
"The absence of evidence is not evidence of absence."
"infinite diversity in infinite combinations"
***
"The absence of evidence is not evidence of absence."