Handling current date and time for gpt 3.5

I am building a bot which schedules an appointment for the customers, I add current date in prompt in order to get date and time in MM/dd/yyyy and hh:mm:ss tt format string, I have test cases in it works properly, but it is not 100% accurate. Does somebody have same kind of experience or what are other solutions to handle current date ?

Personally I would just tell the bot to put a place holder value for the date. In python it would be something like {{date_time_placeholder}} (jinja2 format) and then you post process the response before you send it to the customer.

Python Templating Primer

1 Like

That’s the phrase of ambiguity here.

You gave the AI the date, and it doesn’t use that? You can make it more specific and code-like, with unmistakable D/M/Y:
Conversation start: {"Current Date and Time": "2023-07-17T22:30:00Z", "Local Time Zone": -5}

Scheduling an appointment sounds more like you’d be using a time a different way: interpreting a return value from a function ##available_appointments, or setting one with API function ##reserve_appointment_date_time

So handle just means enhancing your AI’s understanding of what it needs to do, just like enhancing our understanding of what you need to do.

1 Like

I have working hours on one hand and on the other hand user messages, e.g: Can I schedule an appointment tomorrow at 6 pm, I am extracting date/time expression form user message and format it in proper date/time format string.
what happens is? it extracts “tomorrow” but sometimes formats it on wrong date.

1 Like

Few things that work for me,

I tell the AI to use ISO Date format and I pass it the current date in ISO format, then dates like “tomorrow” tend to be accurate.


There are multiple worldwide schemas of date that the language model may have been trained on, so discovering the day that comes after 08/08/2023 may be quite a difficult task to predict.

I would specify particular things the AI needs to know in sprompt description or in clear function parameter descriptions, such as the below prompt enhancement, which may be good to reinforce for any date-based AI application:

[Date input/output format]
Preferred: September 14, 2023
Compact: 14-Sep-2023
API: “09/14/2023”
Scheduling: “09/14/2023 14:30”

I haven’t tried pushing one, but I expect there is no output of a “example”: “xxx” in a JSON function to the AI. It would have to be in the description.

1 Like