dateGenerate in query

MarioP1
Tera Contributor

Hello,

I need to get records between specific dates:

var query = 'state=3^closed_atBETWEENjavascript:gs.dateGenerate('2018-11-17','00:00:00')@javascript:gs.dateGenerate('2019-01-31','23:59:59')'; //Nov 17 2018 to Jan 31 2019

Please help in correcting above query or suggest better option.

Thanks

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Seems fine but I will use below.

var query = "state=3^closed_atBETWEENjavascript:gs.dateGenerate('2018-11-17','00:00:00')@javascript:gs.dateGenerate('2019-01-31','23:59:59')";

 So, as to avoid system to get confused between quotes.

View solution in original post

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

Hi,

 

Seems fine but I will use below.

var query = "state=3^closed_atBETWEENjavascript:gs.dateGenerate('2018-11-17','00:00:00')@javascript:gs.dateGenerate('2019-01-31','23:59:59')";

 So, as to avoid system to get confused between quotes.

Hitoshi Ozawa
Giga Sage
Giga Sage

As Jaspal said, you're using all single quotes. It's necessary to alternate between single and double quotes or escape them.

Further information on quotes can be read in the following tutorial.

Check sections "Using the Alternate String Syntax", "Using the Escape Character (\)", "Using Template Literals"

https://www.digitalocean.com/community/tutorials/how-to-work-with-strings-in-javascript#:~:text=Usin...

MarioP1
Tera Contributor

Thanks Jaspal and Hozawa for your help.