Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type conversion in U-SQL

Tags:

u-sql

I am very new to USQL and wondering how to cast a "datetime" to "date" in a select statement. Also, how do i get rid of the millisecond and am/pm? I'd really appreciate any help on this. Thank you all.

like image 407
enufeffizy Avatar asked Oct 19 '22 09:10

enufeffizy


2 Answers

Below is the code that works.Notice the parenthesis.

@date =
SELECT (datevalue).ToString("MM-dd-yyyy") AS date
FROM @datetime;
like image 135
enufeffizy Avatar answered Jan 04 '23 06:01

enufeffizy


You can use inline C# to do that.

@rowset = SELECT dateTimeColumn.Date AS dateOnly FROM @anotherrowset;

To get rid of values you can use the dateTime.ToString(format), e.g. dateTime.ToString("mm/dd/yy hh:mm).

like image 29
Rukmani Gopalan Avatar answered Jan 04 '23 06:01

Rukmani Gopalan