I am using the GPT-4.0 model with Azure AI Foundry. It is not connecting to the internet and is returning the wrong date and time. What should I do?

Deepankar 205 Reputation points
2025-05-17T20:17:09.5866667+00:00

I have built a hospital appointment scheduling bot using GPT-4.0. I'm facing an issue where the bot is unable to detect today's date or tomorrow's date when users ask to book an appointment. It seems to be fetching the date from when GPT-4.0 was trained. I've tried rephrasing the prompt "to connect to the internet to fetch the current date", but it doesn't work. The bot only proceeds with the booking if I specify the date explicitly. Can someone suggest how to overcome this issue with GPT-4.0? I prefer not to switch to GPT-4.1 at this time. Is there any solution?

Check this playground done at Azure AI Foundry with the model below

User's image

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,624 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sina Salam 22,031 Reputation points Volunteer Moderator
    2025-05-18T23:59:42.91+00:00

    Hello Deepankar,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are using the GPT-4.0 model with Azure AI Foundry and it is not connecting to the internet and is returning the wrong date and time.

    By default, Azure AI Foundry does not have real-time access to the internet or the current date. However, it can be integrated with external APIs or tools to retrieve real-time data if configured accordingly. Do not rely on GPT-4.0 to infer dates, inject them explicitly since that's a common limitation.

    You can do the followings to fully implement your Azure Foundry:

    1. Use Azure Function to get current date by creating an Azure Function that returns the current date and time in ISO format.
         import datetime
         import azure.functions as func
         def main(req: func.HttpRequest) -> func.HttpResponse:
             now = datetime.datetime.now(datetime.timezone.utc)
             return func.HttpResponse(now.isoformat())
      
      https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python
    2. In your app logic (e.g., Python or Node.js), fetch the date from the Azure Function and prepend it to the user prompt:
         prompt = f"Today is {current_date}. User: {user_input}"
      
      https://learn.microsoft.com/en-us/training/modules/apply-prompt-engineering-azure-openai/
    3. Use a library like Chrono (JavaScript) or dateparser (Python) to convert natural language dates into actual dates before sending to GPT.
         import dateparser
         parsed_date = dateparser.parse("next Monday", settings={'RELATIVE_BASE': datetime.now()})
      
      https://github.com/sisyphsu/dateparser
    4. Make sure the server and user time zones are aligned. Use pytz or zoneinfo to convert times.
         from pytz import timezone
         manila_time = datetime.now(timezone('Asia/Manila'))
      

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.