Hello All,
i am trying to get current system time as
DECLARE @now Datetime= DateTime.Now();
Here I am getting PST time but i want to display EST time.
So how can I achieve this?
Hello All,
i am trying to get current system time as
DECLARE @now Datetime= DateTime.Now();
Here I am getting PST time but i want to display EST time.
So how can I achieve this?
@subhodeepchakraborty-1896 Thanks for using Microsoft Q&A !!
You can use Function like below to convert local DateTime to specific timezone -
DECLARE @func Func<DateTime,DateTime> = (d) => {
TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime.SpecifyKind(d, DateTimeKind.Local);
DateTime estTime = TimeZoneInfo.ConvertTime(d, cstZone);
return estTime;
};
@data =
SELECT data FROM
( VALUES
(DateTime.UtcNow)) AS T(data);
@result =
SELECT @func(data).ToString("dd-MM-yyyyThh:mm:ss") AS data FROM @data;
OUTPUT @result
TO "datafolder/data.csv"
USING Outputters.Tsv();

Result:
Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.
Hi @SaurabhSharma-msft ,
This Works sweet. Thank you.
Also Can you please tell me, How I can Append this converted EST Datetime in the output file name?
@subhodeepchakraborty-1896 Great to hear that it works. I need to check that as the function is not a constant-foldable expression in U-SQL. I will get back to you on the same.
Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.
6 people are following this question.