Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting yyyymmdd 00:00:00 parameter into mm/dd/yyyy 00:00:00 string

Status
Not open for further replies.

ifthenelsenull

Technical User
Nov 17, 2011
31
US
I have a parameter displaying yyyymmdd 00:00:00 I need to turn into a string because it can be null and I want to substitute a message for that case. I have not had any luck with cstr, totext, tonum or any of the standard conversions. I think I remember this using left right and mid to swap out the date part but I'm drawing a blank on what to do with the time.

Code:
Date (cstr (Right ({?@enddate}, 4)),
      cstr (Mid ({?@enddate}, 5, 2)),
      cstr (Left ({?@enddate}, 2))
     )

The code isn't working but I think this is part of the way there. Any help you can provide is appreciated.
 
First off is the parameter a datetimee? If so the Right ({?@enddate}, 4) will return the time part. Assuming that the parameter is in the form yyyymmdd 00:00:00. The change the formula to the following.
Date (cstr (left ({?@enddate}, 4)),
cstr (Mid ({?@enddate}, 5, 2)),
cstr (MId ({?@enddate}, 7,2))
)
Hopefully that will work.
 
Maybe I have misunderstood, but if you need to convert a Date/Time to a String, use:

Code:
ToText({?enddate}, 'yyyy/MM/dd 00:00:00')

The construction of the 'yyyy/MM/dd 00:00:00' can be changed to produce the date in the format you need.

Cheers
Pete
 
OK, just realised the Date format you wanted. Assuming you want to retain the Time in the format hh:mm:ss, amend the earlier code to:

Code:
ToText({?enddate}, 'MM/dd/yyyy hh:mm:ss')

Cheers
Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top