IS there a macro Method to Convert DateTime to SQl DateTime format?

benyamin jain asked on September 19, 2016 15:01


I want to use CurrentDateTime macro in SQl Query. But the returned date is not compatible with sql date string format.

also how i can convert datetime using invariant culture in macro.

say my date time format is in hijry , I need to convert result of CurrentDateTime to sql date string format using invariant culture format.

SELECT * from cms_users where UserCreatedWhen = {%CurrentDateTime.ToString("s")%} 
// this can be true for georgian cultures but if my culture set to another culture like fa-ir i need to use InvariantCulture in ToString Method.(How i can do this)

not these all must be down using macro.

Is there any way?

Correct Answer

Dawid Jachnik answered on September 19, 2016 15:11

Or with format:

CurrentDateTime.Format("{0:yyyy-MM-dd HH:mm:ss}")
0 votesVote for this answer Unmark Correct answer

Recent Answers

Jan Hermann answered on September 19, 2016 15:09

Try this:

UserCreatedWhen = '{%Now%}'

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.