Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Date_Trunc

Status
Not open for further replies.

NateUNI

MIS
Jan 3, 2002
132
US
When I run the following statement,

INSERT INTO public."Bug Status" ("Tracking Number", "Assigned Analyst", status, "Changed By", "Updated Date") VALUES
(111111111, 'NS', 'Reported', 'NS', DATE_TRUNC('second', 'current_timestamp'));

I recieve the following error:
ERROR: function date_trunc("unknown", "unknown") is not unique
HINT: Could not choose a best candidate function. You may need to add explicit type casts.

Does anyone know how to solve this problem, Thanks!!
 
you should not put current_timestamp in '

i.e.

DATE_TRUNC('second', current_timestamp)
 
If I take away the ( ' ) I recieve the following error:

ERROR: unterminated string
CONTEXT: compile of PL/pgSQL function "update_status" near line 3
 
Basically all I want to do is get the current time/date to the second, not the persision the is defaulted to current_timestamp. Could I maybe write a date format statement? Thanks!
 
if you did

INSERT INTO public."Bug Status" ("Tracking Number", "Assigned Analyst", status, "Changed By", "Updated Date") VALUES
(111111111, 'NS', 'Reported', 'NS', DATE_TRUNC('second', current_timestamp));

I can't see why you get unterminated string ;-((

can you give an example of what is your intend, because I didn't get the idea sorry ;-(
 
maybe post your update_status function. it's probably just some data making it from your web-based form being posted to postgresql without being properly escaped (pg_addslashes() with php).

----
JBR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top