Author |
Message |
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|
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 Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
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 Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|
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 Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
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 Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|
Posted: 09 Sep 2016 at 7:40am |
I am so sorry. that should have read 20160909
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
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 Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|
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 Logged |
|
|