Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, how should the script be like if I want a column 'before 10am' to be 1 if the column 'time' is >=10:00:00, else it will be 0? Thanks.
Hi Rachel,
you could use this expression:
if(hour([timefield]) < 10, 1, 0) as [before 10 am]
Marcus
Why did you start duplicate thead?
Original thread: How to use if then statement to create new column
Try this in the script
If(Your_Column_Name<10:00:00 ,1, 0) as New_Column
Make sure you give the Appropriate date format in the condition above,
Hope this helps you.
Regards,
Manideep.
Thanks, but apparently I cant put comma no matter what I do...
Please check whether the date format is appropriate or not.
if you are writing if condition in preceding load make sure you put semicolon at the end.
Eg:
Load *, if(condition) as New_Column;
Load
A,
B,
C
From <Path>
Or else post your script in which you need the condition.
i think this will work:
if(Time(YourField)<MakeTime(10),1,0)
This is my script:
LOAD * INLINE [
Before 10am,
];
if([Time])<10:00:00,1,0) as [Before 10am];
The underlined colon after '10' has error. Thanks.
Hey thanks for your answer, but the comma after (10) has error.
Try this
LOAD *, if(Hour(Timestamp(Time,'hh:mm:ss'))<10,1,0) as before10am;
LOAD * Inline [
Time
10:00:00,
11:00:00,
9:00:00
];
This should work