Dear All,
As you might have guessed, I'm currently working on a number of reports using different date formats.
I've come up with the following formula to convert YYYYMMDDHHMMSS string to a Crystal DateTime value.
All you guru's who came up with this years ago, please accept my apologies for boring you....All those who, like me, have spent hours taking the mid values, converting them to numbers and building the datetime, Enjoy!
My test date shown is 1st January 2003, 23:59:59
datetime(date(picture(left("20030101235959",8),"xxxx,xx,xx"),time(picture(right("20030101235959",6),"xx:xx:xx"))
The above formula can be used for any format, YYMMDDHHMMSS, YYYYMMDDHHMM, etc. with simple changes to the left and right functions, and the picture format:
YYMMDDHHMMSS
datetime(date(picture(left("030101235959",6),"20xx,xx,xx"),time(picture(right("030101235959",6),"xx:xx:xx"))
YYYYMMDDHHMM
datetime(date(picture(left("200301012359",8),"xxxx,xx,xx"),time(picture(right("200301012359",4),"xx:xx"))
Any comments would be appreciated, including if anyone has a better way of doing this.
Reebo
Scotland (Sunny with a Smile)
As you might have guessed, I'm currently working on a number of reports using different date formats.
I've come up with the following formula to convert YYYYMMDDHHMMSS string to a Crystal DateTime value.
All you guru's who came up with this years ago, please accept my apologies for boring you....All those who, like me, have spent hours taking the mid values, converting them to numbers and building the datetime, Enjoy!
My test date shown is 1st January 2003, 23:59:59
datetime(date(picture(left("20030101235959",8),"xxxx,xx,xx"),time(picture(right("20030101235959",6),"xx:xx:xx"))
The above formula can be used for any format, YYMMDDHHMMSS, YYYYMMDDHHMM, etc. with simple changes to the left and right functions, and the picture format:
YYMMDDHHMMSS
datetime(date(picture(left("030101235959",6),"20xx,xx,xx"),time(picture(right("030101235959",6),"xx:xx:xx"))
YYYYMMDDHHMM
datetime(date(picture(left("200301012359",8),"xxxx,xx,xx"),time(picture(right("200301012359",4),"xx:xx"))
Any comments would be appreciated, including if anyone has a better way of doing this.
Reebo
Scotland (Sunny with a Smile)