从一张表中获取日期时间并将其存储在另一张表中

时间:2019-05-24 12:54:42

标签: javascript node.js express

我从一个table->row获取日期,并将同一日期存储在另一个表中,但是当我从第一个表获取日期时,其格式像'2019-05-16T13:28:08.000Z'一样更改,错误的格式存储在第二个表中

{
    build_Data = await query (`SELECT
                                  build_Date, 
                                  house,
                                  bench,
                                  unit_measure, 
                                  motherstock_id, 
                                  created_at
                              FROM tbl_builds 
                              WHERE id = ${req_params.build_id}`
                             );

    let build_date = build_Data[0].build_Date;
    let house = build_Data[0].house;
    let bench = build_Data[0].bench;
    let unit_measure = build_Data[0].unit_measure;
    let motherstock_id = build_Data[0].motherstock_id;
    let created_at = build_Data[0].created_at;
    console.log(created_at, build_date);


    result = await query(`
       INSERT INTO tbl_move_builds (
        build_date,
        action,
        house,
        bench, 
        unit_measure,
        pots_moved,
        pots_damaged,
        damage_reason,
        motherstock_id, 
        created_at
        ) VALUES (
        '${build_date}',
        '${req_data.action}',
        ${house},
        ${bench},
        ${unit_measure},
        ${req_data.pots_moved},
        '0',
        '0',
        ${motherstock_id},
        ${created_at}
      )
        `
    );
}

我想获取要存储在其他表中的正确日期时间格式

0 个答案:

没有答案