---
schema_version: "1"
id: edfc5423c5e89094ef111d81fbbd9262f824bd109cd6e931b6f8fcb8f41c5507
title: Variables in AMPscript
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/guide/language-basics/mc-ampscript-guide-language-basics-variables.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/guide/mc-ampscript-guide-language-basics-variables.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1011b6e25eebfbe924ae44772ca0f2f3e5f35279ea47338235aee79f20b43231
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# Variables in AMPscript

AMPscript variable names always begin with the at sign (@).

## Declaring Variables

You can declare a variable using the `Var` keyword. When you declare a keyword, it is added to a dictionary of variables. The value of a newly declared variable is `null`. You can only declare variables in AMPscript blocks. In other words, you can't declare variables in inline AMPscript strings.

This example declares a variable called "firstName".

```
%%[
  Var @firstName
]%%
```

You can use the `Var` keyword to declare multiple values in a single line. This example declares the "firstName", "lastName", and "contactCity" variables.

```
%%[
  Var @firstName, @lastName, @contactCity
]%%
```

## Setting Variables

Use the `Set` keyword to assign a new value to a variable. This example declares the variable "contactCity" and sets its value to "Tokyo".

```
%%[
  Var @contactCity
  Set @contactCity = "Tokyo"
]%%
```

You can set the value of a variable to the value of a function. This example sets the "currentDate" variable to the current date using the `FormatDate()` and `Now()` functions.

```
%%[
  Var @currentDate
  Set @currentDate = FormatDate(Now(), "d MMMM yyyy")
]%%
```

If the current date is August 5, 2023, the "currentDate" variable would have the value "5 August 2023".
