Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
NoobAnalyst01
Helper I
Helper I

How to add 1 hours to a DateTime Data

Hello,

 

I have a dateset the I want to a customs date filter on query editor, which wil help me do the following as SQL:

 

SCANDATE BETWEEN TRUNC(SYSDATE)+(1/24) AND TRUNC(SYSDATE)+1

 

So I use

 

= Table.SelectRows(CARTONTRACKING1, each [SCANDATE] >= Date.From(DateTime.LocalNow())+#duration(0, 1, 0, 0) and [SCANDATE] <=  Date.From(DateTime.LocalNow())+#duration(0, 24, 0, 0))

 

becasue my [SCANDATE] is a datetime type

 

Trying to first trunc the system time to for exmaple 6/4/2018 12:00:00 AM then add 1 hours so it becomes 6/4/2018 1:00:00 AM, 

 

 

But it gives me a error

 

Expression.Error: We cannot apply operator < to types Date and DateTime.
Details:
    Operator=&lt;
    Left=6/4/2018
    Right=11/2/2011 10:31:49 PM
1 ACCEPTED SOLUTION

@NoobAnalyst01

In the Modeling Ribbon there is a Data type that you can convert from date time to date and vice versa.

View solution in original post

6 REPLIES 6
Hauke
Helper I
Helper I

You can just use the "&" I guess: Date.From(DateTime.LocalNow())&#time(1, 0, 0)

Jorgast
Resolver II
Resolver II

i try 

 

= Table.SelectRows(CARTONTRACKING1, each [SCANDATE] >= Date.From(DateTime.LocalNow())+#time(1, 0, 0) and [SCANDATE] <=  Date.From(DateTime.LocalNow())+#time(1, 0, 0))

 

but it said 

 

Expression.Error: We cannot apply operator + to types Date and Time.
Details:
Operator=+
Left=6/4/2018
Right=1:00:00 AM

 

I think I  have to first conver Date.From(DateTime.LocalNow()) to datetime, becuase Date.From(DateTime.LocalNow()) give me date type not date time. but not sure how to do that

@NoobAnalyst01

In the Modeling Ribbon there is a Data type that you can convert from date time to date and vice versa.

I got it, using:

 

#datetime(Date.Year(Date.From(DateTime.LocalNow())),Date.Month(Date.From(DateTime.LocalNow())),Date.Day(Date.From(DateTime.LocalNow())),1,0,0)

Thanks 

 

Not sure I undestand or not, what I expect is for example

 

6/4/2018 1:00:00 AM

 

Date.From(DateTime.LocalNow())  will give me 6/4/2018 but thre is no time, since it is a date type, so I am not aboe to add 1 hours to this.  I need first make 6/4/2018 to 6/4/2018 12:00:00 AM

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.