SQL.GetFieldAsDate
------------------

Returns field's value as date value; converts if needed.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [2.6](newinversion26.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.GetFieldAsDate"; Command; Field ) 

**MBS**( **"SQL.GetFieldAsDate";** /\* Returns field's value as date value; converts if needed. \*/  
**$Command**; /\* The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). \*/   
**$Field**) /\* The name or one based index of the field. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Command | The command reference number gained with [SQL.NewCommand](SQLNewCommand.md). | $Command |
| Field | The name or one based index of the field. | $Field |

### Result

Returns date value or error message.

### Description

Returns field's value as date value; converts if needed.  
  
see also:  
[https://www.sqlapi.com/ApiDoc/class\_s\_a\_field.html](https://www.sqlapi.com/ApiDoc/class_s_a_field.html)  
### Examples

Read null value as empty, otherwise get date:

 If(  
 MBS ("[SQL.GetFieldIsNull](SQLGetFieldIsNull.md)"; $command ; "FieldName");   
 "";  
 MBS ("SQL.GetFieldAsDate"; $command ; "FieldName"))  
### See also

- [SQL.ConvertDateTimeFromSQL](SQLConvertDateTimeFromSQL.md)
- [SQL.GetFieldAsDateTime](SQLGetFieldAsDateTime.md)
- [SQL.GetFieldAsNumber](SQLGetFieldAsNumber.md)
- [SQL.GetFieldAsPDF](SQLGetFieldAsPDF.md)
- [SQL.GetFieldAsText](SQLGetFieldAsText.md)
- [SQL.GetFieldAsTime](SQLGetFieldAsTime.md)
- [SQL.GetFieldName](SQLGetFieldName.md)
- [SQL.GetFieldValue](SQLGetFieldValue.md)
- [SQL.GetParamAsDate](SQLGetParamAsDate.md)
- [SQL.NewCommand](SQLNewCommand.md)

### Release notes

- **Version 8.0**
    - Fixed [SQL.GetFieldAsDate](http://www.mbsplugins.eu/SQLGetFieldAsDate.shtml) to assign a date and not a timestamp.

### Example Databases

- [SQL to other databases/MySQL example](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/MySQL%20example.shtml#3ScriptAnchor_)
- [SQL to other databases/SQLite fun](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20fun.shtml#3ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 8.0pr7](https://www.mbsplugins.de/archive/2018-01-10/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 25th February 2021

  
[SQL.GetFieldAsContainer](SQLGetFieldAsContainer.md) - [SQL.GetFieldAsDateTime](SQLGetFieldAsDateTime.md)

[HTML Version](SQLGetFieldAsDate.shtml)