Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: convert string to date Post Reply Post New Topic
Author Message
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Topic: convert string to date
    Posted: 09 Sep 2016 at 4:50am
hi, is there a way to convert a string (2016099) for example, into a date field, that i could use to select certain records for my report ?

Edited by Kitty1 - 09 Sep 2016 at 4:50am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 09 Sep 2016 at 5:27am
Maybe, what would the value 2016099 convert to as a date?  You probably would use the Date function with the left, mid and right functions (and Val to convert the different parts to numbers).
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Sep 2016 at 5:44am
thank you, would you be able to show me the formula i would use ?   i don't just need it to print the date in a different format, i need it to be a date field and not a string field.

Edited by Kitty1 - 09 Sep 2016 at 5:44am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 09 Sep 2016 at 7:38am
That I why I asked what 2016099 would convert to as a date.  Normally a string field that represents a date is either six or eight characters long, not seven.  
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Sep 2016 at 7:40am
I am so sorry. that should have read 20160909

IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 09 Sep 2016 at 7:57am
Okay assuming that 2016 is the year and the first 09 is the month.  Then this should work (provided there are no nulls).

date(val(left({stringfield},4)),val(mid({stringfield},5,2)), val(right({stringfield},2)))
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Sep 2016 at 8:16am
thank you so much, that worked!!! have a great weekend!


Edited by Kitty1 - 09 Sep 2016 at 8:16am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.