Zum Inhalt springen

select & timestamp [where]

Erstellt am 23. Januar 2008 · 5 Antworten · letzte Antwort am 23. Januar 2008

Tags: Frage

jeppo ·

Hallo,

aus eine Tabelle mit der Spalte <date> möchte ich auf die datensätze mit select zugreifen die älter oder gleich sind als das aktuelle timestamp.
Folgende script habe ich geschrieben, es funktioniert es auch solange ich anstatt das dynamische aktuelle timestamp (date:U) einen statisches timestamp manuell schreibe wie z.B. 1201010816. Es muss was mit string zu tun haben, aber irgendwie komme ich nicht dahinter.

Kann mir hier jemand helfen?

...
table = tx_calendar_dates
select {
	pidInList = 337
	where = date >= date:U???
	orderBy = date
	max = 2		
}
...

Vielen Dank im Voraus.

mfg

Jeppo

jeppo ·

Hallo Georg,

auch mit addWhere geht es leider nicht :-(

...
table = tx_calendar_dates
select {
	pidInList = 337
	addWhere = date >= date:U???
	orderBy = date
	max = 2		
}
...
just2b ·

schmeiss im install tool das sqldebug an, dann siehst du was rauskommt!

aber vom gefühl her wird das nicht umgewandelt

        andWhere {
                data = date:U
                wrap =  date >=|
        }

georg

jeppo ·

toll den sqldebug kannte ich noch nicht, danke ;-)

In der Tat wurde date:U nicht umgewandelt, im debug stand da "you have an error in your SQL syntax near ':U" und als ausgabe stand date:U anstatt den timestamp.
Zum schluss hat aber funktioniert, ich musste nur noch einen Tag abziehen und vorallem addWhere in andWhere ändern, da hattest du dich vertipt?

...
table = tx_calendar_dates
select {
        pidInList = 337
        andWhere {
        data = date:U-84600
        wrap =  date >=|
        }
        orderBy = date
        max = 2  
}
...

Nochmal danke ;-) !