How to insert date in date field type from frappeclient?

I’m trying to insert date through frappeclient but getting Internal Server Error in response. What is the proper way to insert date in date field type?

Hi @Ramit_Panangat,

Please share your code.



def lambda_handler(event, context):
    client = FrappeClient("")
    client.authenticate(environ.get("api"), environ.get("api_secret"))
    data = json.loads(event["body"])
    doc = client.insert({
        "doctype": "Operator Policy Issued",
        "operator": data["operator"],
        "name1": data["name1"],
        "gender": data["gender"],
        "nationality": data["nationality"],
        "start_date": datetime.strfdate('23-04-2022', '%d/%m/%Y')

Hi @Ramit_Panangat,

can you try this like only ‘‘2022-04-23’’ without datetime.strfdate

Tried that too…but didn’t worked

hi @Ramit_Panangat

datetime.strptime('23-04-2022', '%d/%m/%Y')

please try this.


I just tried and still not working

Last option like


Hi @Ramit_Panangat,

What error show in insert time?

I’m trying to run frappeclient in AWS lambda. Can’t import frappe there.
This is the error I get while using datetime module.

Test Event Name

  "errorMessage": "'body'",
  "errorType": "KeyError",
  "requestId": "cc50821d-d0b8-45e2-a44b-2c6acdad4c13",
  "stackTrace": [
    "  File \"/var/task/\", line 11, in lambda_handler\n    data = json.loads(event[\"body\"])\n"

Function Logs
START RequestId: cc50821d-d0b8-45e2-a44b-2c6acdad4c13 Version: $LATEST
[ERROR] KeyError: 'body'
Traceback (most recent call last):
  File "/var/task/", line 11, in lambda_handler
    data = json.loads(event["body"])END RequestId: cc50821d-d0b8-45e2-a44b-2c6acdad4c13
REPORT RequestId: cc50821d-d0b8-45e2-a44b-2c6acdad4c13	Duration: 18.78 ms	Billed Duration: 19 ms	Memory Size: 128 MB	Max Memory Used: 49 MB	Init Duration: 319.54 ms

Request ID

Hi @Ramit_Panangat,

If you have not checked then check it, please.

Maybe it helps you.


Actually problem with frappe.utils is that I can’t import that in AWS lambda.

Hi @Ramit_Panangat,

Sorry for disturbing you.
Please again try this if you have not tried it.

datetime.datetime.strptime('23-04-2022', '%d/%m/%Y')

Otherwise, change the format and then checks it.

Thank You!

No no. You are helping me.
I already tried datetime.datetime.strptime('23-04-2022', '%d/%m/%Y') but not working.

Hi @Ramit_Panangat,

date = "2022-04-23"
frappe.utils.datetime.datetime.strptime(date, "%d-%m-%Y")


frappe.utils.datetime.datetime.strptime('23-04-2022', "%d-%m-%Y")

Please set your according to.