AMBRISHBHATIA
Programmer
I have date as 23/04/2017 and I want it to be in 23-Apr-2017 so that I export this is in .CSV file as a date format. How can I do this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
AMBRISHBHATIA said:I have date as 23/04/2017
* Will that be how the Text should appear within the CSV file?23-Apr-2017
* Where ldDate is a Date or Datetime
lcChar = TRANSFORM(DAY(ldDate)) + "-" + LEFT(CMONTH(ldDate), 3) + "-" + TRANSFORM(YEAR(ldDate))
* lcChar now contains the date in the required format
ldDate = DATE()
SET DATE TO DMY
? ldDate
SET DATE TO MDY
? ldDate
SET DATE TO YMD
? ldDate
*!* GetFormatedDateByWindows
*!* See also: [URL unfurl="true"]https://www.berezniker.com/[/URL]
Lparameters TCDATE
#Define LOCALE_USER_DEFAULT 0x400
? Transform(Day(m.TCDATE))+'-'+Proper(GetformatedDate(m.TCDATE,LOCALE_USER_DEFAULT,"MMM"))+'-'+Transform(Year(m.TCDATE))
Function GetformatedDate(tdDate, tnLocale, tvFlagsOrFormat)
Local lcDate, lcFormat, lcDateStr, lnDateStrLen, lnFlags
Do Case
Case Vartype(m.tvFlagsOrFormat) = "N"
lnFlags = m.tvFlagsOrFormat
lcFormat = ""
lcFormat = Null
Case Vartype(m.tvFlagsOrFormat) = "C"
lnFlags = 0
lcFormat = m.tvFlagsOrFormat
Otherwise
Assert .F. Message "Missing or Invalid 3rd parameter."
Endcase
* SYSTEMTIME Structure. Only Year, Month and Day members are relevant.
lcDate = ;
BINTOC(Year(m.tdDate), "2RS") + ;
BINTOC(Month(m.tdDate), "2RS") + BinToC(0, "2RS") + ;
BINTOC(Day(m.tdDate), "RS") + BinToC(0, "8RS")
lnDateStrLen = 255
lcDateStr = Space(m.lnDateStrLen)
lnDateStrLen = GetDateFormat(m.tnLocale, m.lnFlags, m.lcDate, m.lcFormat, @m.lcDateStr, m.lnDateStrLen)
lcDateStr = Left(m.lcDateStr, m.lnDateStrLen - 1)
Return m.lcDateStr
Endfunc
Function GetDateFormat(Locale, dwFlags, lpDate, lpFormat, lpDateStr, cchDate)
Declare Long GetDateFormat In win32api As GetDateFormat ;
Long Locale, Long dwFlags, String lpDate, String lpFormat, String @lpDateStr, Long cchDate
Return GetDateFormat(m.Locale, m.dwFlags, m.lpDate, m.lpFormat, @m.lpDateStr, m.cchDate)
Endfunc