# Current Date in Mercury

**URL:** https://talk.remobjects.com/t/current-date-in-mercury/23009
**Category:** Mercury
**Created:** [September 3, 2020, 2:07pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009 "2020-09-03T14:07:27Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![richard1](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/r/50afbb/32.png) [@richard1](https://talk.remobjects.com/u/richard1)
#### Post date: [September 3, 2020, 2:07pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/1 "2020-09-03T14:07:27Z")

</div>

How do you get the current date time in mercury? Now() and Date$ do not work.

---

<div class="post-metadata">

### Author: ![marcvanbreemen](https://talk.remobjects.com/user_avatar/talk.remobjects.com/marcvanbreemen/32/16420_2.png) [@marcvanbreemen](https://talk.remobjects.com/u/marcvanbreemen)
#### Post date: [September 3, 2020, 2:09pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/2 "2020-09-03T14:09:00Z")

</div>

```
DateTime.Now
```

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [September 3, 2020, 2:26pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/3 "2020-09-03T14:26:17Z")

</div>

@mh: Now() should have worked - can you add this as missing keyword?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 3, 2020, 2:27pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/4 "2020-09-03T14:27:19Z")

</div>

What platform? .NET’s System.DateTime as “Now”, but Elements RTL’s DateTime class has only `UtcNow`.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 3, 2020, 2:28pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/5 "2020-09-03T14:28:06Z")

</div>

> [@Theo69](#):
>
> @mh: Now() should have worked - can you add this as missing keyword?

is Now() a global function provided by Visual Basic? If so, we can add it to MBL, of course.

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [September 3, 2020, 2:28pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/6 "2020-09-03T14:28:46Z")

</div>

Correct.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 3, 2020, 2:30pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/7 "2020-09-03T14:30:21Z")

</div>

Sure? Where is this defined? Google only finds me DateTime.Now(), and a Now() function in VBA/VB6…

---

<div class="post-metadata">

### Author: ![Theo69](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@Theo69](https://talk.remobjects.com/u/Theo69)
#### Post date: [September 3, 2020, 2:33pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/8 "2020-09-03T14:33:19Z")

</div>

It is coming from the VisualBasic.dll.  
Module DateAndTime, function Now

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 3, 2020, 2:34pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/9 "2020-09-03T14:34:44Z")

</div>

Ah yes. thats in MBL already, just disabled (because it didn’t compile, at some stage). lemme see if I can enable it.

---

<div class="post-metadata">

### Author: ![marcvanbreemen](https://talk.remobjects.com/user_avatar/talk.remobjects.com/marcvanbreemen/32/16420_2.png) [@marcvanbreemen](https://talk.remobjects.com/u/marcvanbreemen)
#### Post date: [September 3, 2020, 2:42pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/10 "2020-09-03T14:42:56Z")

</div>

Now() is part of the Microsoft.VisualBasic namespace. In VS Mac I have to add a reference to it and then import that namespace first before I can actually use it.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [September 3, 2020, 3:24pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/11 "2020-09-03T15:24:14Z")

</div>

IIRC it’s logged for next week for “RemObjects.Elements.Mercury” and (by extension, where available, Microsoft.ViksualBasic" to automatically be in the Imports scope, for .vb files. That means on .NET you’ll then have these APIs automatically — until them the workaround would be to add the namespace as Imports or to the “Default Uses” setting (see “Project|Manage Namespaces” in Fire/Water, or manually set the setting, in VS).

A distinction needs to be made between whats .NET APIs and what’s the VB/Mercury _language_. DateTime.Now and Now() are .NET APIs, and .NET APIs all not be available on the platforms, per se.

Some, very common VB-specific APIs we will provide, where feasible and scope allowing, on all platforms, via the [Mercury Base Library](https://docs.elementscompiler.com/API/MercuryBaseLibrary/). `Now()` _might_ become one of those APIs.

[Elements RTL](https://docs.elementscompiler.com/API/ElementsRTL/) is the best set of shared APIs to use, for platform-agnostic code; it works with Mercury but is designed for _all_ Elements languages (and platforms).

---

<div class="post-metadata">

### Author: ![richard1](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/r/50afbb/32.png) [@richard1](https://talk.remobjects.com/u/richard1)
#### Post date: [February 23, 2021, 10:08pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/12 "2021-02-23T22:08:52Z")

</div>

As of build 10.0.0.2605 this still does not work. Now or Now() gives an error…“Did you mean low”" Well no compiler I meant now.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [February 23, 2021, 10:30pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/13 "2021-02-23T22:30:39Z")

</div>

Do you have Microsoft.VisualBasic in the Imports?

```auto
Imports Microsoft.VisualBasic

Module Program

  Sub Main(args as String())
    writeLn("The magic happens here.")
    writeLn(Now())
  End Sub

End Module

```

builds fine for me.

---

<div class="post-metadata">

### Author: ![richard1](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/r/50afbb/32.png) [@richard1](https://talk.remobjects.com/u/richard1)
#### Post date: [February 23, 2021, 11:58pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/14 "2021-02-23T23:58:27Z")

</div>

Interesting that if I copy the contents of the file over to water it does not compile, but if I import it it compiles. Lesson learned.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [February 24, 2021, 12:01pm UTC](https://talk.remobjects.com/t/current-date-in-mercury/23009/15 "2021-02-24T12:01:06Z")

</div>

Richard,

can I see a test case project where this does not compile? I assume you Ade sure you had the `Imports Microsoft.VisualBasic` line?
