Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get CurrentTime from SQL Server with LINQ/Entities/VB.Net

I am using LINQ with Entity Framework, and I need to get the SQL server time. Can anyone tell me how can I create a method so it retrieves the current server time? Thank you.

like image 272
Reigo Hein Avatar asked Jan 01 '26 11:01

Reigo Hein


1 Answers

Just execute a ExecuteStoreQuery command.

Dim dateTimeVal As DateTime = context.ExecuteStoreQuery(Of DateTime)("select getdate()").First()
like image 118
Eranga Avatar answered Jan 03 '26 05:01

Eranga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!