How can I convert the dates in the formats below to" YYYY-MM-DD?
thanks,
Walt
# The date value on the file to be imported is in the following formats:
# m/d/yyyy
# mm/d/yyyy
# mm/dd/yyyy
# SUBST(string, beginning, length)
sMonth = SUBST(v_order_day,0,(SCAN( '/', v_order_day)-1));
sDayMonth = SUBST(v_order_day,(SCAN( '/', v_order_day)+1), Long(v_order_day));
sYear = SUBST(sDayMonth,(SCAN( '/', sDayMonth)+1), Long(sDayMonth));
sDay = SUBST(sDayMonth,0,(SCAN( '/', sDayMonth)-1));
# DATES(1998, 2, 10) returns '1998-02-10' # convert date to number.
sOrderDateString = DATES(sYear, sMonth, sDay); ----this does not work function expects numbers
l_OrderDateSerial = DayNo( sOrderDateString );
Thanks,
Walt
Date Conversion with Zero Padding
- mattgoff
- MVP
- Posts: 518
- Joined: Fri May 16, 2008 1:37 pm
- OLAP Product: TM1
- Version: 10.2.2.6
- Excel Version: O365
- Location: Florida, USA
Re: Date Conversion with Zero Padding
Check out NUMBR.
Matt
Matt
Please read and follow the Request for Assistance Guidelines. It helps us answer your question and saves everyone a lot of time.
-
- Community Contributor
- Posts: 132
- Joined: Thu Oct 15, 2009 7:45 pm
- OLAP Product: TM1
- Version: 9.4.1 9.5 9.5.1
- Excel Version: 2003 2007
Re: Date Conversion with Zero Padding
sMonth = SUBST(v_order_day,0,(SCAN( '/', v_order_day)-1));
sDayMonth = SUBST(v_order_day,(SCAN( '/', v_order_day)+1), Long(v_order_day));
sYear = SUBST(sDayMonth,(SCAN( '/', sDayMonth)+1), Long(sDayMonth));
sDay = SUBST(sDayMonth,0,(SCAN( '/', sDayMonth)-1));
# convert to numeric values
nMonth = NUMBR( sMonth );
nDay = NUMBR( sDay );
nYear = NUMBR( sYear );
# DATES(1998, 2, 10) returns '1998-02-10' # convert date to number.
sOrderDateString = DATES(nYear, nMonth, nDay); ----this does not work function expects numbers
l_OrderDateSerial = DayNo( sOrderDateString );
sDayMonth = SUBST(v_order_day,(SCAN( '/', v_order_day)+1), Long(v_order_day));
sYear = SUBST(sDayMonth,(SCAN( '/', sDayMonth)+1), Long(sDayMonth));
sDay = SUBST(sDayMonth,0,(SCAN( '/', sDayMonth)-1));
# convert to numeric values
nMonth = NUMBR( sMonth );
nDay = NUMBR( sDay );
nYear = NUMBR( sYear );
# DATES(1998, 2, 10) returns '1998-02-10' # convert date to number.
sOrderDateString = DATES(nYear, nMonth, nDay); ----this does not work function expects numbers
l_OrderDateSerial = DayNo( sOrderDateString );
Ankur Jain
Re: Date Conversion with Zero Padding
Thank You. NUMBER works!
# The date value on the file to be imported is in the following formats:
# m/d/yyyy
# mm/d/yyyy
# mm/dd/yyyy
# Example: SUBST(string, beginning, length)
sDayYear = SUBST(v_order_day,(SCAN( '/', v_order_day)+1), Long(v_order_day));
nMonth = NUMBR(TRIM(SUBST(v_order_day,1,(SCAN( '/', v_order_day)-1))));
nYear = NUMBR(TRIM(SUBST(sDayYear,(SCAN( '/', sDayYear)+1), Long(sDayYear))));
nDay = NUMBR(TRIM(SUBST(sDayYear,1,(SCAN( '/', sDayYear)-1))));
# ASCIIOutput('c:\helpme.txt', sDayYear, nMonth , nYear, nDay );
# Example: DATES(1998, 2, 10) returns '1998-02-10'
sOrderDateString = DATES(nYear, nMonth, nDay);
# Convert Date to Serial number.
l_OrderDateSerial = DayNo(sOrderDateString);
# The date value on the file to be imported is in the following formats:
# m/d/yyyy
# mm/d/yyyy
# mm/dd/yyyy
# Example: SUBST(string, beginning, length)
sDayYear = SUBST(v_order_day,(SCAN( '/', v_order_day)+1), Long(v_order_day));
nMonth = NUMBR(TRIM(SUBST(v_order_day,1,(SCAN( '/', v_order_day)-1))));
nYear = NUMBR(TRIM(SUBST(sDayYear,(SCAN( '/', sDayYear)+1), Long(sDayYear))));
nDay = NUMBR(TRIM(SUBST(sDayYear,1,(SCAN( '/', sDayYear)-1))));
# ASCIIOutput('c:\helpme.txt', sDayYear, nMonth , nYear, nDay );
# Example: DATES(1998, 2, 10) returns '1998-02-10'
sOrderDateString = DATES(nYear, nMonth, nDay);
# Convert Date to Serial number.
l_OrderDateSerial = DayNo(sOrderDateString);