Forum Discussion
kamleshyadav95
Jul 09, 2024Copper Contributor
date format getting changed from yyyy-mm-dd hh:mm:ss:fff to dd-mm-yyyy hh:mm
Hi All, I am trying to export data from sql server database to csv. data is getting export perfectly in csv file but date format is getting from "yyyy-mm-dd hh:mm:ss:fff" to "dd-mm-yyyy hh:mm". ...
kamleshyadav95
Jul 10, 2024Copper Contributor
Hi Lain,
Thanks for response i am using same format as needed but "HH" component extra getting added.
$OriginalCulture = $host.CurrentCulture.DateTimeFormat.Clone();
$host.CurrentCulture.DateTimeFormat.LongDatePattern = "yyyy-MM-dd";
$host.CurrentCulture.DateTimeFormat.LongTimePattern = "HH:mm:ss.fff";
LainRobertson
Jul 10, 2024Silver Contributor
That's unexpected and not in line with my screenshot from above, which does not feature the extra "HH".
What happens if you run the following line after the original three you've repeated above?
$host.CurrentCulture.DateTimeFormat | Format-List -Property *pattern;
You should see an enumeration of the various formats as shown below, with the change in format reflected in the FullDateTimePattern property:
Cheers,
Lain
- kamleshyadav95Jul 10, 2024Copper ContributorHi Lain,
Yes, Agree I can see that but not sure why this is not coming correctly.
Kamlesh