Search code examples
sql-serverdateformatpowerbuilder

PB Select TODAY() Into :var From DUMMY


When I get TODAY in SELECT in PB, it returns 1900/1/1

date var
Select TODAY() Into :var From DUMMY

But when I assign to variable TODAY(), it works as expected

date var
var = today()

I use MS SQL Server 2016 and PowerBuilder 12.5.

I've supposed that the problem is in different date formats, but I have changed date format at my Windows locale in the way, that PB TODAY() returns 2018-10-08 and MSSQL GetDate() returns 2018-10-08 18:25:23.207 So date parts have the same formats.

The problem is not in DUMMY table since I have created MS SQL DUMMY table and inserted 1 row in it.

Also I'm wondering if there are any difference in SELECT TODAY() and var = TODAY()? I suppose that 1st variant returns MS SQL server time but 2nd returns local time. Is not is?


Solution

  • Try below SQL.

    Select getdate() into :var From DUMMY;